package com.theunderminejournal.updater.gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class ErrorDialog extends JDialog implements ActionListener {

	
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 4806682579847552079L;

	    private JPanel myPanel = null;
	    private JButton okButton = null;
	    private boolean answer = false;
	    
	    public boolean getAnswer() { return answer; }

	    public ErrorDialog(JFrame frame, boolean modal, String myMessage) {
	        super(frame, modal);
	        myPanel = new JPanel();
	        getContentPane().add(myPanel);
	        myPanel.add(new JLabel(myMessage));

	        okButton = new JButton("Ok");
	        okButton.addActionListener(this);
	        myPanel.add(okButton); 

	        pack();
	        setLocationRelativeTo(frame);
	        setVisible(true);
	    }

	    public void actionPerformed(ActionEvent e) {
	        if(okButton == e.getSource()) {
	            answer = true;
	            setVisible(false);
	        }
	    }
	    
}
